$.validator.setDefaults({
	submitHandler: function() { alert("submitted!"); },
	errorPlacement: function(error, element) {
		error.appendTo(element.parent());
	},
	errorClass: "invalid",
	errorElement: "span"
});


/**
 * leftside.jsp
 */
var leftside = {
	/**
	 * 菜单点击
	 * 
	 * @param url
	 */	
	menuClick : function(id, url) {
		$curli = $("#nav .selected").removeClass("selected").removeClass("heading"); 
		$curspan = $curli.children("span");
		$curspan.replaceWith($("<a></a>").text($curspan.text()).attr("href", $curspan.attr("data")));
		
		$li = $("#" + id).addClass("selected").addClass("heading");
		$a = $li.children("a");
		$a.replaceWith($("<span></span>").text($a.text()).attr("data", $a.attr("href")));
		
		//@ajax.postHtml("right_main", url);
		rightside.load(url);
	},
	
	popup : function() {
		$("#notificationsbox").bPopup();
	}	
		
};

var rightside = {
		
	load : function(url) {
		$("#right_main").ajaxPost(url);
	},
	
	html : function(data) {
		$("#right_main").html(data);
	},
	
	showEditDialog : function(url) {
		$("#edit_dialog").ajaxPost(url);
		$("#edit_dialog").bPopup({
			fadeSpeed : 1,
			followSpeed : 1,
			opacity : 0.8,
			position : ['auto','auto'],
			modalClose : false
		});		
	},
	
	modalForm : function(formId) {
		$("#" + formId).ajaxForm({
			contentType : "application/x-www-form-urlencoded; charset=utf-8",
			type : 'POST',
			beforeSubmit : function() {
				$("#edit_dialog").bPopup().close();
				$("#right_main").ajaxLoader();
			},
			success : function(data) {
				rightside.html(data);
			}
		});
	},

	closeStatusBar : function() {
		$("#status_bar .status").css("display", "none");
	},	

	showErrorBar : function(error) {
		rightside.closeStatusBar();
		$("#status_bar #error_content").text(error);
		$("#status_bar .status").filter(".error").css("display", "block");
	},

	showWarnBar : function(warn) {
		rightside.closeStatusBar();
		$("#status_bar #warn_content").text(warn);
		$("#status_bar .status").filter(".warning").css("display", "block");
	},
	
	showInfoBar : function(info) {
		rightside.closeStatusBar();
		$("#status_bar #info_content").text(info);
		$("#status_bar .status").filter(".info").css("display", "block");
	},
	
	showSuccessBar : function(success) {
		rightside.closeStatusBar();
		$("#status_bar #success_content").text(success);
		$("#status_bar .status").filter(".success").css("display", "block");
	}

};




